<!DOCTYPE html>
<html lang="zh">
<head>
    <title>{$title|default='^v^'}</title>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=0.4">
    <link rel="stylesheet" href="__STATIC__/layui/css/layui.css">
    <script src="__STATIC__/jquery-v3.6.0.min.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <style>
        .demo-login-container{
            width: 320px;
            margin: 21px auto 0;
        }
        .demo-login-other .layui-icon{
            position: relative;
            display: inline-block;
            margin: 0 2px;
            top: 2px;
            font-size: 26px;
        }
    </style>
</head>
<body class="layui-bg-gray">
<br><br>
<form class="layui-form">
    <div class="demo-login-container">
        {:token_field()}
        <div class="layui-form-item">
            <h2 style="text-align:center;">{$name|default='^v^'}</h2>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-wrap">
                <div class="layui-input-prefix">
                    <i class="layui-icon layui-icon-username"></i>
                </div>
                <input type="text" name="account" value="" lay-verify="required" placeholder="用户名" lay-reqtext="请填写用户名" autocomplete="off" class="layui-input" lay-affix="clear">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-wrap">
                <div class="layui-input-prefix">
                    <i class="layui-icon layui-icon-password"></i>
                </div>
                <input type="password" name="password" value="" lay-verify="required" placeholder="密   码" lay-reqtext="请填写密码" autocomplete="off" class="layui-input" lay-affix="eye">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-row">
                <div class="layui-col-xs7">
                    <div class="layui-input-wrap">
                        <div class="layui-input-prefix">
                            <i class="layui-icon layui-icon-vercode"></i>
                        </div>
                        <input type="text" name="captcha" value="" lay-verify="required" placeholder="验证码" lay-reqtext="请填写验证码" autocomplete="off" class="layui-input" lay-affix="clear">
                    </div>
                </div>
                <div class="layui-col-xs5">
                    <div style="margin-left: 10px;">
                        <img id="captcha_url" width="150" src="{:url('/admin/get-captcha')}" onclick="this.src='{:url('/admin/get-captcha')}?'+Math.random();" alt="captcha" />
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="formDemo">登录</button>
        </div>
    </div>
</form>
</body>
<script>
    layui.use(['form', 'laydate'], function(){
        var form = layui.form;
        // form.render('select');
        //监听提交
        form.on('submit(formDemo)', function(data){
            //当前容器的全部表单字段，名值对形式：{name: value}
            // console.log(data.field);
            // layer.msg(JSON.stringify(data.field));
            $.ajax({
                url: "{$uri}",
                method: "post",
                data: data.field,
                dataType: "JSON",
                success: function (callback){
                    //console.log(callback);
                    layer.msg(callback.message);
                    if (callback.code === 1)
                    {
                        setTimeout(function(){
                            location.href = "/admin/index";
                        }, 1000);
                    }
                }
            });
            return false;
        });
    });
</script>
</html>